<?php
    session_start(); 
?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link media="screen" rel="stylesheet" href="colorbox/colorbox.css" />
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
	<script src="colorbox/jquery.colorbox.js"></script>

<?php

include "config.php";
if(isset($_POST["done"])){
    $email = $_POST["email"];
    $password = $_POST["password"];
    
    $sql = "SELECT * FROM `vt_register` WHERE `email`='$email'";  
    $re = mysql_query($sql);
    while($rows = mysql_fetch_array($re)) {
        if(mysql_num_rows($re)> 0){
            if($rows["password"] == md5($password)){
                 $_SESSION['id'] = $rows["id"];
                 $_SESSION['email'] = $rows["email"];
                 $_SESSION['name'] = $rows["firstname"];
                ?>
                <script>
                    alert("Ðăng nhập thành công");
                    window.location.href="../users/users_index.php";
                </script>
                <?php
                
            }
            else {
                ?>
                <script>
                    alert("email hay mật khẩu không đúng");
                    window.location.href="../login.php";
                </script>
                <?php
            } 
        }
    }
}
?>